package com.shopnight.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shopnight.entity.Rider;
import com.shopnight.mapper.UserMapper;
import com.shopnight.service.RiderService;
import com.shopnight.mapper.RiderMapper;
import com.shopnight.vo.RiderInfoVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

/**
* @author 13201
* @description 针对表【rider】的数据库操作Service实现
* @createDate 2023-04-16 17:29:24
*/
@Service
public class RiderServiceImpl extends ServiceImpl<RiderMapper, Rider>
    implements RiderService{
    @Autowired
    RiderMapper riderMapper;
    @Autowired
    UserMapper userMapper;

    @Override
    public RiderInfoVo riderInfo(Integer userId) {
        Rider rider = riderMapper.selectOne(
                new LambdaQueryWrapper<Rider>()
                        .eq(Rider::getUserId, userId)
        );
        RiderInfoVo riderInfoVo = new RiderInfoVo();
        BeanUtils.copyProperties(rider,riderInfoVo);
        riderInfoVo.setAvatar(userMapper.selectById(rider.getUserId()).getAvatar());

        return riderInfoVo;

    }
}




